#pragma once
#include "lib.h"

class A
{
	friend int operator<(const A &l, const A &r) {
		if (l.a < r.a) return -1;
		if (r.a < l.a) return 1;
		return 0;
	}
public:
	A(int a) : a(a) {}
private:
	int a;
};

template <typename XXX>
int compare(const XXX &v1, const XXX &v2) {
	if (v1 < v2) return -1;
	if (v2 < v1) return 1;
	return 0;
}

namespace han {
	template <typename Iterator, typename Value>
	auto find(Iterator first, Iterator last, Value const& value) {
		for (; first != last && *first != value; ++first);
		return first;
	}
}

template <typename T,unsigned N>
void print(T (&p)[N]) {
	for (auto elem : p) {
		cout << elem << " ";
	}
	cout << endl;
}

template <typename T, unsigned N>
T* mybegin(T(&p)[N]) {
	return p;
}

template <typename T, unsigned N>
T* myend(T(&p)[N]) {
	return N+p;
}

template<typename T, unsigned N>
constexpr unsigned getSize(const T(&)[N]) {
	return N;
}

template <typename T>
class Foo
{
public:
	static std::size_t count() { return ctr; }
	static void setCount(size_t ct) { ctr = ct; }
private:
	static std::size_t ctr;
};

class DebugDelete
{
public:
	DebugDelete(ostream &os = std::cerr) : os(os) {}
	template <typename T>
	void operator()(T *p) const {
		os << "deleting unique_ptr" << endl;
		delete p;
	}
private:
	ostream &os;
};

class MyBad {

public:
	MyBad() {}
	MyBad(const MyBad&) = delete;
private:
	int a = 0;
};